#ifndef TRIE_H
#define TRIE_H

#include "GlobalMacros.h"
#include "Shield.h"

#include <unordered_map>
#include <vector>
#include <string>
#include <memory>

NAMESPACE_BEGIN
extern template class DS_API nmspc::Shield<std::vector<std::string>>;
typedef nmspc::Shield<std::vector<std::string>> SVectorString;

class DS_API Trie
{
protected:
	std::unordered_map<char, std::unique_ptr<Trie>> children;
	bool if_end;
public:
	Trie();
	~Trie();
public:
	Trie(const Trie&) = delete;
	Trie& operator= (const Trie&) = delete;
public:
	Trie* search(const std::string& prefix);
	bool inserted(const std::string& whole_word);
	void insert(const std::string& word);
	void erase(const std::string& word);
	void getSuffix(SVectorString& all_suffix, std::string& cur_suffix = std::string());
	SVectorString getSuffix(const std::string& prefix = "");
};
NAMESPACE_END

#endif // !TRIE_H
